package com.myown.enums;

/**
 * 通用状态码枚举定义 <p>
 * @author lincky
 * @version v1.0.0
 */
public enum CommonStatus {
    SUCCESS(0, "成功"),
    ILLEGAL_CHARACTERS(1, "存在非法字符"),
    NOT_FOUND(2, "不存在"),
    EXSISTED(3, "已存在");

    private int code;
    private String value;

    public int getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    CommonStatus(int code, String value) {
        this.code = code;
        this.value = value;
    }

    public static CommonStatus valueOf(int index) {
        for (CommonStatus commonStatus : CommonStatus.values()) {
            if (commonStatus.getCode() == index) {
                return commonStatus;
            }
        }
        return null;
    }
}
